package org.example.config;

import java.io.*;

public class PdfDownloadUtil {

    public static byte[] readFileAsBytes(String filePath) throws IOException {
        File file = new File(filePath);
        try (FileInputStream in = new FileInputStream(file);
             BufferedInputStream bf = new BufferedInputStream(in)) {
            byte[] bytes = new byte[(int) file.length()];
            bf.read(bytes);
            return bytes;
        }
    }

    public static void downloadPdf(String pdfFilePath, String saveFilePath) throws IOException {
        byte[] pdfBytes = readFileAsBytes(pdfFilePath);
        try (FileOutputStream fos = new FileOutputStream(saveFilePath)) {
            fos.write(pdfBytes);
        }
    }
}